﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TruckerSale.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <!--#include virtual="include/Head.ascx"-->
    <script type="text/javascript" language="javascript">
        function doDelete(strID, strName) {
            if (confirm('Bạn có thực sự muốn xóa ' + strName + '?')) {
                var vnpage = getUrlVars()['page_number'];
                var vChar = getUrlVars()['letter'];
                var strHref = "";
                if (vnpage)
                    strHref = "TruckerSale.aspx?action=delete&ID=" + strID + "&page_number=" + vnpage;
                else
                    strHref = "TruckerSale.aspx?action=delete&ID=" + strID;

                if (vChar)
                    window.location.href = strHref + "&letter=" + vChar;
                else
                    window.location.href = strHref;
            }
        }
        function OpenCustomer(sender, url) {
            if (!($(sender).parent().hasClass("editing") || $("#btnupdate").val() == "Done") && $(sender).text() != "") {
                window.open(url, "customer", "height:400,top=0,toolbar=no,directories=no,location=no,menubar=no,status=no");
            }
        }
        function getUrlVars() {
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        }
        $().ready(function () {
            var nsuperAdmin = '<%Response.Write(nPermissions.ToString()); %>'
            if (nsuperAdmin < 9) $('#slAll').hide();
            var vID = getUrlVars()["ID"];
            if (vID)
                $("#addnewbox").show();
            $("#btnAddNew").click(function () {
                if ($(this).val() == "Add new") {
                    $("#addnewbox").show();
                    $(this).val("Hide");
                }
                else {
                    $("#addnewbox").hide();
                    $(this).val("Add new");
                }
            });
        });
    </script>
</head>
<body>
    <div id="body-wrapper">
        <div id="header">
            <!--#include virtual="include/top.ascx"-->
        </div>
        <div id="main-content1">
            <h2></h2>
            <div class="clear">
            </div>
            <div class="content-box" style="width: 100%;">
                <form id="frmEdit" runat="server" autocomplete="off">
                    <%      
                        if (nPermissions >= 3)
                        {%>
                    <div id="addnewbox" style="display: none;">
                        <div class="content-box-header">
                            <h3 style="cursor: s-resize;">Trucker Sale: Add [Edit]
                            </h3>
                            <div class="clear">
                            </div>
                        </div>
                        <table class="adminedit" style="width: 100%;">
                            <tr>
                                <th align="center">Trucker
                                </th>
                                <th align="center">Location
                                </th>
                                <th align="center">PIC
                                </th>
                                <th align="center">Advantage
                                </th>
                                <th align="center">Tel
                                </th>
                                <th align="center">Cell
                                </th>
                                <th align="center">Skype
                                </th>
                                <th align="center">Email
                                </th>
                                <th align="center">Car
                                </th>
                                <th align="center">Rank
                                </th>
                                <th align="center">Service Area
                                </th>
                                <th align="center">Note
                                </th>
                            </tr>
                            <tr>
                                <td>
                                    <asp:DropDownList class="cls" ID="ddTrucker" runat="server" Width="120px">
                                    </asp:DropDownList>
                                </td>
                                <td>
                                    <asp:DropDownList class="cls" ID="ddLocation" runat="server" Width="105px">
                                    </asp:DropDownList>
                                </td>
                                <td>
                                    <asp:TextBox class="cls" ID="txtPIC" runat="server" Width="75px"></asp:TextBox>
                                </td>
                                <td>
                                    <asp:TextBox class="cls" ID="txtAdvantage" runat="server" Width="90px" TabIndex="7"
                                        Style="text-align: right;"></asp:TextBox>
                                </td>
                                <td>
                                    <asp:TextBox class="cls" ID="txtTel" runat="server" Width="90px" Style="text-align: right;"></asp:TextBox>
                                </td>
                                <td>
                                    <asp:TextBox class="cls" ID="txtCell" runat="server" Width="90px" Style="text-align: right;"></asp:TextBox>
                                </td>
                                <td>
                                    <asp:TextBox class="cls" ID="txtSkype" runat="server" Width="100px" Style="text-align: right;"></asp:TextBox>
                                </td>
                                <td>
                                    <asp:TextBox class="cls" ID="txtEmail" runat="server" Width="100px" Style="text-align: right;"></asp:TextBox>
                                </td>
                                <td>
                                    <asp:TextBox class="cls" ID="txtNumberCar" runat="server" Width="40px" Style="text-align: right;"></asp:TextBox>
                                </td>
                                <td>
                                    <asp:TextBox class="cls" ID="txtRank" runat="server" Width="50px" Style="text-align: right;"></asp:TextBox>
                                </td>
                                <td>
                                    <asp:TextBox class="cls" ID="txtServiceArea" runat="server" Width="200px" TextMode="MultiLine"
                                        Rows="3" Style="text-align: right;"></asp:TextBox>
                                </td>
                                <td>
                                    <asp:TextBox class="cls" ID="txtNote" runat="server" Width="200px" TextMode="MultiLine"
                                        Rows="3" Style="text-align: right;"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                        <asp:Label ID="lblError" class="error" runat="server"></asp:Label>
                        <table class="paramlist admintable" width="100%">
                            <tr>
                                <td colspan="2">
                                    <asp:Button class="button" ID="btnSave" runat="server" Text="Cập nhật" OnClick="btnSave_Click" />
                                </td>
                            </tr>
                        </table>
                    </div>
                    <%} %>
                    <div class="content-box-header">
                        <h3 style="cursor: s-resize;">TruckerSale</h3>
                        <asp:DropDownList ID="ddPicSales" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddPicSales_SelectedIndexChanged">
                        </asp:DropDownList>
                        &nbsp;
                    <asp:DropDownList ID="ddTruckers" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddTruckers_SelectedIndexChanged">
                    </asp:DropDownList>
                        <asp:DropDownList ID="ddLocationSearch" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddLocationSearch_SelectedIndexChanged">
                        </asp:DropDownList>
                        <%if (nPermissions > 3)
                          { %>
                        <input id="btnAddNew" type="button" style="float: right; margin: 9px 10px;" class="button"
                            value="Add new" />
                        <%} %>
                        <div class="clear">
                        </div>
                    </div>
                    <%if (nPermissions >= 7)
                      { %>
                    <%=strAlphaBet%>
                    <%} %>
                    <fieldset>
                        <asp:Repeater ID="rptData" runat="server">
                            <ItemTemplate>
                                <tr onmouseover="this.style.background='#dbf0c9'" onmouseout="this.style.background='#ffffff'">
                                    <td align="center">
                                        <%# DataBinder.Eval(Container.DataItem, "Index")%>
                                    </td>
                                    <td code="BizName" completesource="trucker" style="font-weight: bold;">
                                        <%# DataBinder.Eval(Container.DataItem, "BizName") %>
                                    </td>
                                    <td code="LocationName">
                                        <%# DataBinder.Eval(Container.DataItem, "LocationName") %>
                                    </td>
                                    <td code="Pic" style="text-decoration: underline; color: Blue;" onclick='OpenCustomer(this,"<%# GetCustomerLink(DataBinder.Eval(Container.DataItem, "ID"),DataBinder.Eval(Container.DataItem, "PicID")) %>")'>
                                        <%# DataBinder.Eval(Container.DataItem, "Pic") %>
                                    </td>
                                    <td code="Advantage">
                                        <%# DataBinder.Eval(Container.DataItem, "Advantage") %>
                                    </td>
                                    <td code="Tel">
                                        <%# DataBinder.Eval(Container.DataItem, "Tel") %>
                                    </td>
                                    <td code="Cell">
                                        <%# DataBinder.Eval(Container.DataItem, "Cell") %>
                                    </td>
                                    <td code="Skype">
                                        <%# DataBinder.Eval(Container.DataItem, "Skype") %>
                                    </td>
                                    <td code="Email">
                                        <%# DataBinder.Eval(Container.DataItem, "Email")%>
                                    </td>
                                    <td code="NumberCar">
                                        <%# DataBinder.Eval(Container.DataItem, "NumberCar")%>
                                    </td>
                                    <td code="Rank">
                                        <%# DataBinder.Eval(Container.DataItem, "Rank")%>
                                    </td>
                                    <td code="ServiceArea">
                                        <%# DataBinder.Eval(Container.DataItem, "ServiceArea")%>
                                    </td>
                                    <td code="Note">
                                        <%# DataBinder.Eval(Container.DataItem, "Note")%>
                                    </td>
                                    <%if (nPermissions >= 3)
                                      { %>
                                    <td>
                                        <div class="changed">
                                            <%# DataBinder.Eval(Container.DataItem, "Action")%>
                                        </div>
                                    </td>
                                    <%} %>
                                </tr>
                            </ItemTemplate>
                            <HeaderTemplate>
                                <table cellspacing="0" cellpadding="0" width="100%" border="0" class="adminlist"
                                    editcellcontent="true">
                                    <thead>
                                        <tr style="background: #CCC;">
                                            <th align="center" width="30px">Index
                                            </th>
                                            <th align="center" width="100px">Trucker
                                            </th>
                                            <th align="center" width="80px">Location
                                            </th>
                                            <th align="center" width="80px">PIC
                                            </th>
                                            <th align="center">Advantage
                                            </th>
                                            <th align="center">Tel
                                            </th>
                                            <th align="center">Cell
                                            </th>
                                            <th>Skype
                                            </th>
                                            <th align="center">Email
                                            </th>
                                            <th align="center" width="60px">NCar
                                            </th>
                                            <th align="center">Rank
                                            </th>
                                            <th align="center">Service Area
                                            </th>
                                            <th align="center">Note
                                            </th>
                                            <%if (nPermissions >= 3)
                                              { %>
                                            <th align="center" width="75px">Action
                                            </th>
                                            <%} %>
                                        </tr>
                                    </thead>
                            </HeaderTemplate>
                            <FooterTemplate>
                                </TABLE>
                            </FooterTemplate>
                        </asp:Repeater>
                    </fieldset>
                    <div class="clear">
                    </div>
                    <div id="footer">
                        <%=strPager%>
                    </div>
                </form>
            </div>
        </div>
    </div>
</body>
</html>
